package com.quasar.hpatient.presenter;

import com.quasar.hpatient.model.httpmodel.AnotherResult;
import com.quasar.hpatient.model.medicalmodel.DiagnoseListData;
import com.quasar.hpatient.model.medicalmodel.ListDiagnose;
import com.quasar.hpatient.model.medicalmodel.TestPresentationData;
import com.quasar.hpatient.model.requestmodel.RequestModel;
import com.quasar.hpatient.onInterface.AnotherResultListener;
import com.quasar.hpatient.onInterface.OnDiagnoseListListener;
import com.quasar.hpatient.onInterface.viewInterface.UiInterface;
import com.quasar.hpatient.view.adapter.TestrecordsItemAdapter;

/**
 * author : 许建宏
 * Date: 2017/10/31 0031
 * View:获取化验历史时间
 */

public class LaboratoryDatePresenter {

    private RequestModel requestModel;
    private OnDiagnoseListListener uiInterface;



    public LaboratoryDatePresenter(OnDiagnoseListListener uiInterface) {
        this.requestModel = new RequestModel();
        this.uiInterface = uiInterface;
    }


    public void PostLaboratoryDate(final String startTime, final String endTime){

        requestModel.HistoryLaboratorys(startTime, endTime, new AnotherResultListener<AnotherResult<TestPresentationData>>() {
            @Override
            public void onSuccess(AnotherResult<TestPresentationData> data) {
                uiInterface.onLaboratorySuccess(data);
                PostDiagnoseDate(startTime,endTime);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onViewError(msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onViewRefreshUI();
            }
        });


    }

    //获取诊断信息
    public void PostDiagnoseDate(String startTime,String endTime){
        requestModel.DiagnoseListData(startTime, endTime, new AnotherResultListener<AnotherResult<DiagnoseListData>>() {
            @Override
            public void onSuccess(AnotherResult<DiagnoseListData> data) {
                uiInterface.onDiagnoseSuccess(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onViewError(msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onViewRefreshUI();
            }
        });

    }

    //获取化验日期信息
    public void GetPatientInspectionListAndDiagnoseData(String startTime,String endTime){

        requestModel.GetPatientInspectionListAndDiagnoseList(startTime, endTime, new AnotherResultListener<ListDiagnose>() {
            @Override
            public void onSuccess(ListDiagnose data) {
                uiInterface.NewTestSuccess(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onViewError(msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onViewRefreshUI();
            }
        });
    }

}
